﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Thor.Configuration;

namespace Thor.Configuration.Test
{
    /// <summary>
    /// Summary description for ConfigurationSettingsTest
    /// </summary>
    [TestClass]
    public class ConfigurationSettingsTest
    {
        #region generated code

        public ConfigurationSettingsTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        #endregion

        #region test methods

        [TestMethod]
        [Description("Configuration")]
        public void AppSettingsTest()
        {
            ConfigurationSettings target = new ConfigurationSettings();

            Assert.AreEqual(target.ApplicationNameKey, "ApplicationName");
            Assert.AreEqual(target.ApplicationNameValue, "Thor");
            Assert.AreEqual(target.ConnectionStringKey, "ConnectionString");
            Assert.AreEqual(target.ConnectionStringValue, "DataConnectionString");
            Assert.AreEqual(target.ContainerAddressKey, "ContainerAddress");
            Assert.AreEqual(target.ContainerAddressValue, "calasmbly");
            Assert.AreEqual(target.SettingsRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.SettingsRepositoryType, "Thor.Repository.Azure.Table.SettingsRepository");
            Assert.AreEqual(target.CalendarRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.CalendarRepositoryType, "Thor.Repository.Azure.Table.CalendarRepository");
            Assert.AreEqual(target.AdministratorAccountRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.AdministratorAccountRepositoryType, "Thor.Repository.Azure.Table.AdministratorAccountRepository");
            Assert.AreEqual(target.InvalidLogonRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.InvalidLogonRepositoryType, "Thor.Repository.Azure.Table.InvalidLogonRepository");
            Assert.AreEqual(target.AssemblyRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.AssemblyRepositoryType, "Thor.Repository.Azure.Blob.ProviderRepository");
            Assert.AreEqual(target.CalendarMonitorInterval, "5");
            Assert.AreEqual(target.InvalidLogonMonitorInterval, "1");
            Assert.AreEqual(target.QueueAddressKey, "QueueAddress");
            Assert.AreEqual(target.QueueAddressValue, "msg");
            Assert.AreEqual(target.MessageRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.MessageRepositoryType, "Thor.Repository.Azure.Queue.MessageRepository");
            Assert.AreEqual(target.CalendarProviderInterfaceName, "Thor.Domain.ICalendarProvider");
        }

        [TestMethod]
        [Description("Configuration")]
        public void CustomSettingsTest()
        {
            ConfigurationSettings target = new ConfigurationSettings(AppDomain.CurrentDomain.BaseDirectory + @"\Thor.Configuration.Application.dll",
                "Thor.Configuration.Application.ApplicationConfigurationSettingsProvider");

            Assert.AreEqual(target.ApplicationNameKey, "ApplicationName");
            Assert.AreEqual(target.ApplicationNameValue, "Thor");
            Assert.AreEqual(target.ConnectionStringKey, "ConnectionString");
            Assert.AreEqual(target.ConnectionStringValue, "DataConnectionString");
            Assert.AreEqual(target.ContainerAddressKey, "ContainerAddress");
            Assert.AreEqual(target.ContainerAddressValue, "calasmbly");
            Assert.AreEqual(target.SettingsRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.SettingsRepositoryType, "Thor.Repository.Azure.Table.SettingsRepository");
            Assert.AreEqual(target.CalendarRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.CalendarRepositoryType, "Thor.Repository.Azure.Table.CalendarRepository");
            Assert.AreEqual(target.AdministratorAccountRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.AdministratorAccountRepositoryType, "Thor.Repository.Azure.Table.AdministratorAccountRepository");
            Assert.AreEqual(target.InvalidLogonRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.InvalidLogonRepositoryType, "Thor.Repository.Azure.Table.InvalidLogonRepository");
            Assert.AreEqual(target.AssemblyRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.AssemblyRepositoryType, "Thor.Repository.Azure.Blob.ProviderRepository");
            Assert.AreEqual(target.CalendarMonitorInterval, "5");
            Assert.AreEqual(target.InvalidLogonMonitorInterval, "1");
            Assert.AreEqual(target.QueueAddressKey, "QueueAddress");
            Assert.AreEqual(target.QueueAddressValue, "msg");
            Assert.AreEqual(target.MessageRepositoryAssembly, @"\Thor.Repository.Azure.dll");
            Assert.AreEqual(target.MessageRepositoryType, "Thor.Repository.Azure.Queue.MessageRepository");
            Assert.AreEqual(target.CalendarProviderInterfaceName, "Thor.Domain.ICalendarProvider");
        }

        #endregion
    }
}
